home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8539 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  41 lines

  1. Newsgroups: comp.lang.c++
  2. Path: cs.vu.nl!pverkai
  3. From: pverkai@cs.vu.nl (Verkaik PD)
  4. Subject: Order of initialisation of static globals
  5. Nntp-Posting-Host: sloep27.cs.vu.nl
  6. Sender: news@cs.vu.nl
  7. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  8. Date: Thu, 15 Feb 1996 16:11:50 GMT
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. Message-ID: <DMtrnr.Mo8.0.-s@cs.vu.nl>
  11.  
  12. I have the following problem.
  13.  
  14. In my programme I have defined a linked list class called lnklist.
  15. I want to make an object O of class lnklist put itself in another lnklist
  16. called queues. In other words, queues is a list of lists one of which is O.
  17. This should happen as part of the construction of O.
  18.  
  19. Queues is a static (global) object in one module. O is also a static (global)
  20. object, only in another module. The problem is that O's constructor is being
  21. called before queues' constructor. O's constructor will attempt to put O
  22. in queues (which happens to work), after which queues will happily initialise
  23. itself removing O as a member...
  24.  
  25. Now, I don't have the Reference Manual handy but I remember looking this
  26. one up before. If I'm correct the RM says something like
  27.  
  28. 'initialisation of static storage is indeterminate, however guarantees that
  29. the data will be initialised before use'
  30.  
  31. which is clearly not the case here.
  32.  
  33. I don't even understand how this rule could possibly be correct, seeing that
  34. it's quite simple to make two classes' constructors call each others' members.
  35.  
  36.  
  37. Anyone?
  38.  
  39.  
  40. Patrick
  41.